package indi.lei;

/**
 * <p>Description:</p> 单例模式
 * <p>Copyright: Copyright (c)2019$</p>
 * <p>Company: Tope</p>
 * <P>Created Date :2019$-09$-26$</P>
 * <P>@version 1.0</P>
 */
public class PrivateConstruct {
    private static PrivateConstruct privateConstruct = null;

    private PrivateConstruct() {
    }

    static PrivateConstruct getNewInstance() {
        if (privateConstruct == null) {
            privateConstruct = new PrivateConstruct();
        }
        return privateConstruct;
    }
}

class Test {
    public static void main(String[] args) {
        /**
         * 判断两个对象是否指向同一个地址
         */
        PrivateConstruct privateConstruct = PrivateConstruct.getNewInstance();
        System.out.println(privateConstruct);
        privateConstruct = PrivateConstruct.getNewInstance();
        System.out.println(privateConstruct);
    }
}
